package com.liuyi.util.excle;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/*import com.liuyi.model.UserApply;
*/
@RestController
public class textController {

	/**
	 * 账号数据导出excel
	 * @param req
	 * @param resp
	 */
	@RequestMapping(value = "/export",method = RequestMethod.GET)
	public void export(HttpServletRequest req,HttpServletResponse resp){
		//LOG.info("ENTER /uas/admin/export,paramter is {}",json);
        //准备数据
      /*  List<UserApply> list = new ArrayList<UserApply>();
        UserApply userApply = new UserApply();
        userApply.setId(10086L);
        userApply.setCourseId(369L);
        userApply.setClassId(200L);
        userApply.setInstitution("ZGHK");
        UserApply userApplys = new UserApply();
        userApplys.setId(10087L);
        userApplys.setCourseId(369L);
        userApplys.setClassId(200L);
        userApplys.setInstitution("ZGHK发放");
        list.add(userApply);
        list.add(userApplys);
		//执行导出
		String fileName = "自定义文件名称.xls";
		ServletUtil su = new ServletUtil(fileName, req, resp);
		su.poiExcelServlet();
		//设置表头
		String[] heads = {"序号","ID","课程ID","班级ID","机构"};
		String[] cols = {"","id","courseId","classId","institution"};
		//这里传第几个字段是数字，从0开始
        int[] numerics = {0,1};
		ServletUtil suresp = new ServletUtil(resp);
		PoiExcelExport<UserApply> pee = new PoiExcelExport<>(fileName, heads, cols, list, numerics, suresp.getOut());
		pee.exportExcel();*/
	}

	public static void main(String[] args) throws Exception {
		String str="E://text.xls";
		String location=str.replace("\\\\", "/");
		Map<Integer,List<List<String>>> sheets = PoiExcelImport.readExcel(location);
		Integer keys = sheets.keySet().size();
		for(int i = 0; i < keys; i++) {
			List<List<String>> sheet = sheets.get(i); //第i个单元格
			System.out.println("返回值为："+sheet);
			for(int j = 1; j < sheet.size(); j++) { //每行
				List<String> lie = sheet.get(j); 
				System.out.println("lie："+lie);
				for(String s : lie) { //每列的值
					System.out.println(s);
				}
			}
		}
	}
}
